package com.kish.dao.impl;

import com.kish.dao.AccountDao;
import com.kish.domain.Account;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.beans.PropertyVetoException;
import java.util.ArrayList;

@Repository
public class AccountDaoImpl implements AccountDao {
    @Resource
    private JdbcTemplate jdbcTemplate;
    @Override
    public ArrayList<Account> getAccounts() {
        return null;
    }

    @Override
    public int addAccount(Account account) throws PropertyVetoException {
        //2、创建JdbcTemplate对象

        //3、设置数据源给JdbcTemplate
        //4、执行操作
        return jdbcTemplate.update("insert into account (id,name,money,updateTime) values (default,?,?,now())",
                account.getName(), account.getMoney());
    }

}
